﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminIndexMaster.master" AutoEventWireup="true" CodeFile="Admin_ShopProduct.aspx.cs" Inherits="Admin_Admin_ShopProduct" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        function checktypeselct() {
            var show_type = document.getElementById("ctl00_ContentPlaceHolder1_show_type");
            if (show_type.value == "ProductID") {
                alert("请先选择排序方式！")
                return false;
            }
            return true;
        }
    </script>
    <script src="../Skin/CommStyle/js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="Js/Function.js" type="text/javascript"></script>
    <table class="adminheading">
        <tr>
            <th valign="middle" class="cpane">
                商城商品管理
            </th>
            <td align="right">
            </td>
            <td class="rtdw">
            </td>
        </tr>
    </table>
    <table class="nick">
        <tr>
            <td colspan="4" class="tit">
                商品查找
            </td>
        </tr>
        <tr>
            <td class="ltd" style="width: 11%;">
                快速查找：
            </td>
            <td class="rtd" style="width: 33%">
                <asp:DropDownList ID="QuickSearch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="QuickSearch_SelectedIndexChanged">
                    <asp:ListItem Text="所有商城商品" Value="all_product" />
                    <asp:ListItem Text="所有未审商品" Value="all_approve" />
                    <asp:ListItem Text="所有上架商品" Value="on_sale" />
                    <asp:ListItem Text="停止销售商品" Value="stop_sale" />
                    <asp:ListItem Text="仓库里的商品" Value="on_stock" />
                    <asp:ListItem Text="商城推荐商品" Value="on_top" />
                    <asp:ListItem Text="卖家推荐商品" Value="saler_recommend" />
                </asp:DropDownList>
                <asp:DropDownList ID="show_type" runat="server" AutoPostBack="true" OnSelectedIndexChanged="show_type_OnChange">
                    <asp:ListItem Text="选择排序方式" Value="ProductID" Selected="True" />
                    <asp:ListItem Text="上架时间排序" Value="BeginDate" />
                    <asp:ListItem Text="价格高低排序" Value="StandPrice" />
                    <asp:ListItem Text="浏览次数排序" Value="Hits" />
                    <asp:ListItem Text="库存大小排序" Value="Stocks" />
                </asp:DropDownList>
                &nbsp;<asp:CheckBox ID="CheckBox1" runat="server" Text="降序" AutoPostBack="true" OnCheckedChanged="CheckBox1_OnChange"
                    onclick="if(!checktypeselct()) return false" />
            </td>
            <td class="ltd" style="width: 11%;">
                高级查找：
            </td>
            <td class="rtd">
                <asp:DropDownList ID="DetailSearchType" runat="server" AppendDataBoundItems="True">
                    <asp:ListItem Selected="True" Value="product_name" Text="按商品名称" />
                    <asp:ListItem Value="saler_name" Text="按卖家名称" />
                    <asp:ListItem Value="product_class" Text="按商品分类" />
                    <asp:ListItem Value="product_place" Text="商品所在地" />
                </asp:DropDownList>
                <asp:TextBox ID="DetailSearchName" runat="server" Width="150px" AutoPostBack="false" />
                <asp:Button ID="AdminSearch" Text=" 查 询 " runat="server" OnClick="AdminSearch_Click" />
            </td>
        </tr>
    </table>
    <div id="product_history">
        <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"
            HeaderStyle-HorizontalAlign="Center" CssClass="adminlist" AllowSorting="True"
            DataKeyNames="ProductID" RowStyle-HorizontalAlign="Center" AutoGenerateColumns="False">
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <input id="chkAll" onclick="SelectAllCheckboxes(this,'chk_select');checkAllByButtonDisable();"
                            runat="server" type="checkbox" />
                    </HeaderTemplate>
                    <HeaderStyle Width="4%"></HeaderStyle>
                    <ItemTemplate>
                        <input type="checkbox" id="chk_select" name="chk_select" onclick="checkAllByButtonDisable();"
                            value='<%# Eval("ProductID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="商品名称" ItemStyle-HorizontalAlign="Left">
                    <ItemTemplate>
                        <asp:HyperLink Target="_blank" ID="ProductNameUrl" runat="server" Text='<%# Bind("ProductName") %>'
                            NavigateUrl='<%#"../ShowProduct.aspx?ProductID="+Eval("ProductID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="卖家名称">
                    <HeaderStyle Width="10%"></HeaderStyle>
                    <ItemTemplate>
                        <asp:HyperLink ID="Saler" runat="server" Text='<%# Bind("SalerId") %>' NavigateUrl='<%#"Admin_UserDetail.aspx?UserID="+Eval("SalerID") %>'
                            Target="_blank" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="类型" HeaderStyle-Width="7%">
                    <ItemTemplate>
                        <asp:Literal ID="ProductType" runat="server" Text='<%# HKB.Web.Shop.TextFormat.GetProductType(Eval("ProductType").ToString()) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="分类">
                    <HeaderStyle Width="10%"></HeaderStyle>
                    <ItemTemplate>
                        <asp:Literal ID="ClassName" runat="server" Text='<%#Eval("ClassName")%>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="StandPrice" HeaderText="价格">
                    <HeaderStyle Width="10%"></HeaderStyle>
                </asp:BoundField>
                <asp:BoundField DataField="Stocks" HeaderText="库存">
                    <HeaderStyle Width="10%"></HeaderStyle>
                </asp:BoundField>
                <asp:TemplateField HeaderText="人气值">
                    <HeaderStyle Width="8%"></HeaderStyle>
                    <ItemTemplate>
                        <asp:Literal ID="Bid_Times_Or_Hits" runat="server" Text='<%#Eval("BidTimes")+"/"+Eval("Hits") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="商品属性">
                    <HeaderStyle Width="10%"></HeaderStyle>
                    <ItemTemplate>
                        <%#Convert.ToBoolean(Eval("IsApprove"))?"已审":"未审" %>
                        <asp:Literal ID="OnTop" runat="server" Text='<%# Eval("OnTop") %>' />
                        <asp:Literal ID="IsHot" runat="server" Text='<%# Eval("IsHot") %>' />
                        <asp:Literal ID="IsPageElite" runat="server" Text='<%# Eval("IsPageElite") %>' />
                        <asp:HiddenField ID="ImgUrl" runat="server" Value='<%# Eval("ProductImageUrl") %>' />
                        <asp:Literal ID="HavePic" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="销售中">
                    <HeaderStyle Width="7%"></HeaderStyle>
                    <ItemTemplate>
                        <asp:Literal ID="ProductOnSale" runat="server" Text='<%# Eval("EnableSingleSell") %>' />
                        <asp:HiddenField ID="ProductOnShopSale" runat="server" Value='<%# Eval("EnableSale") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <%-- <asp:TemplateField HeaderText="操作" >
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="modify" Text="修改" OnClientClick='<%# "javascript:{location.href=\"Admin_ShopProductEdit.aspx?id="+ Eval("ProductID") +"\";return false;}" %>' />
                    </ItemTemplate>
                </asp:TemplateField>--%>
            </Columns>
            <RowStyle HorizontalAlign="Center"></RowStyle>
            <EmptyDataTemplate>
                <tr>
                    <th>
                        ID
                    </th>
                    <th>
                        商品名称
                    </th>
                    <th>
                        卖家名称
                    </th>
                    <th>
                        类型
                    </th>
                    <th>
                        价格
                    </th>
                    <th>
                        库存
                    </th>
                    <th>
                        人气值
                    </th>
                    <th>
                        商品属性
                    </th>
                    <th>
                        销售中
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                <tr>
                    <td colspan="10">
                        暂无商品！
                    </td>
                </tr>
            </EmptyDataTemplate>
            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
        </asp:GridView>
    </div>
    <div class="page">
        <asp:Label ID="PagePanel" runat="server" />
    </div>
    <div class="div_btm" id="divButtons" align="center">
        <asp:Button ID="btnApprove" runat="server" Text="通过审批" CommandName="EnableApprove"
            OnCommand="Button_Command" />
        <asp:Button ID="btnUnApprove" runat="server" Text="取消审批" CommandName="DisableApprove"
            OnCommand="Button_Command" />
        <asp:Button ID="AllowSale_Button" runat="server" Text="设为上架" CommandName="EnableSale"
            OnCommand="Button_Command" />
        <asp:Button ID="StopSale" runat="server" Text="暂时下架" CommandName="StopSale" OnCommand="Button_Command" />
        <asp:Button ID="DisableSale" runat="server" Text="停止上架" CommandName="DisableSale"
            OnCommand="Button_Command" />
        <asp:Button ID="Elite_Button" runat="server" Text="首页推荐" CommandName="PageElite"
            OnCommand="Button_Command" />
        <br />
        <asp:Button ID="CancleElite" runat="server" Text="取消推荐" CommandName="CanclePageElite"
            OnCommand="Button_Command" />
        <asp:Button ID="Button1" runat="server" Text="设为热卖" CommandName="IsHot" OnCommand="Button_Command" />
        <asp:Button ID="Button2" runat="server" Text="取消热卖" CommandName="CancleIsHot" OnCommand="Button_Command" />
        <asp:Button ID="Button3" runat="server" Text="设为置顶" CommandName="OnTop" OnCommand="Button_Command" />
        <asp:Button ID="Button4" runat="server" Text="取消置顶" CommandName="CancleOnTop" OnCommand="Button_Command" />
        <asp:Button ID="Delete_Button" runat="server" Text="单个删除" CommandName="Delete" OnCommand="Button_Command"
            OnClientClick="return confirm('您确定要删除吗？此操作将删除所有跟删除商品相关联的数据，并且删除后不能恢复?')" />
    </div>
    <script type="text/javascript">
        function addProduceonLoad(isChecked) {
            var nodes = document.getElementById('divButtons').childNodes;
            for (var i = 0; i < nodes.length; i++) {
                var node = nodes[i];
                if (node.nodeName == "INPUT" || node.nodeName == "input")
                    node.disabled = (isChecked ? "" : "disabled");
            }

        }
        function checkAllByButtonDisable() {
            var checks = document.getElementsByName('chk_select');
            var isChecked = false;
            for (var i = 0; i < checks.length; i++) {
                var check = checks[i];
                if (check.checked) {
                    isChecked = true;
                    break;
                }
            }
            addProduceonLoad(isChecked);
        }
        addProduceonLoad(false);
    </script>
    <div style="padding: 10px;" align="center">
        <div style="margin-right: 20px;">
            批量设置分类<asp:DropDownList ID="ProductNewClass" DataTextField="ClassName" DataValueField="ClassID"
                runat="server" />
            <asp:Button ID="SetProductNewClassButton" runat="server" Text="确定" OnClick="SetProductNewClassButton_Click"
                OnClientClick="return confirm('确定执行吗？')" /></div>
    </div>
</asp:Content>
